<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //存
        localStorage.setItem('name', 'zhangsan');//两个参数都是字符串
        //取
        let ret = localStorage.getItem('name');
        console.log(ret);
        //删
        localStorage.removeItem('name');



        //如果要存储对象或者数组,要进行序列化和反序列化.
        const obj={
            id:1000,
            name:'张三',
            age:11
        }
        localStorage.setItem('user',JSON.stringify(obj));


    </script>
</body>

</html>